import unittest

from day_02_01_imhr import ImHr
from day_02_03_imhr import CommonTool


class TestImHr(unittest.TestCase):
    def test01_login_ok(self):
        json_data = {"mobile": "13800000002", "password": "123456", "status_code": "", "": "", "": "", }
        res = ImHr.imhr_login(json_data)
        print(res.json())
        CommonTool.assert_succeed(self, res, 200, True, 10000, "操作成功")

    def test02_mobile_none(self):
        json_data = {"mobile": None, "password": "123456"}
        res = ImHr.imhr_login(json_data)
        print(res.json())
        CommonTool.assert_succeed(self, res, 200, False, 20001, "用户名或密码错误")

    def test03_mobile_no(self):
        json_data = {"mobile": "13871055841", "password": "123456"}
        res = ImHr.imhr_login(json_data)
        print(res.json())
        CommonTool.assert_succeed(self, res, 200, False, 20001, "用户名或密码错误")

    def test04_mobile_ten(self):
        json_data = {"mobile": "1387105584", "password": "123456"}
        res = ImHr.imhr_login(json_data)
        print(res.json())
        CommonTool.assert_succeed(self, res, 200, False, 20001, "用户名或密码错误")

    def test05_mobile_twelve(self):
        json_data = {"mobile": "138710558444", "password": "123456"}
        res = ImHr.imhr_login(json_data)
        print(res.json())
        CommonTool.assert_succeed(self, res, 200, False, 20001, "用户名或密码错误")

    def test06_pass_none(self):
        json_data = {"mobile": "138710558444", "password": None}
        res = ImHr.imhr_login(json_data)
        print(res.json())
        CommonTool.assert_succeed(self, res, 200, False, 20001, "用户名或密码错误")

    def test07_pass_special(self):
        json_data = {"mobile": "13800000002", "password": "12345&"}
        res = ImHr.imhr_login(json_data)
        print(res.json())
        CommonTool.assert_succeed(self, res, 200, False, 20001, "用户名或密码错误")

    def test08_pass_one(self):
        json_data = {"mobile": "13800000002", "password": "1"}
        res = ImHr.imhr_login(json_data)
        print(res.json())
        CommonTool.assert_succeed(self, res, 200, False, 20001, "用户名或密码错误")

    def test09_pass_hundred(self):
        json_data = {"mobile": "13800000002",
                     "password": "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890"}
        res = ImHr.imhr_login(json_data)
        print(res.json())
        CommonTool.assert_succeed(self, res, 200, False, 20001, "用户名或密码错误")

    def test010_mobile_special(self):
        json_data = {"mobile": "1380000000$", "password": "123456"}
        res = ImHr.imhr_login(json_data)
        print(res.json())
        CommonTool.assert_succeed(self, res, 200, False, 20001, "用户名或密码错误")

    def test011_mul(self):
        json_data = {"mobile": "13800000002", "password": "123456", "abc": "123"}
        res = ImHr.imhr_login(json_data)
        print(res.json())
        CommonTool.assert_succeed(self, res, 200, True, 10000, "操作成功")

    def test012_and_less(self):
        json_data = {"password": "123456"}
        res = ImHr.imhr_login(json_data)
        print(res.json())
        CommonTool.assert_succeed(self, res, 200, False, 20001, "用户名或密码错误")

    def test012_no_join(self):
        json_data = None
        res = ImHr.imhr_login(json_data)
        print(res.json())
        CommonTool.assert_succeed(self, res, 200, False, 99999, "抱歉，系统繁忙，请稍后重试")
